package agend.behaviours.delete;

import jade.core.AID;
import jade.core.behaviours.OneShotBehaviour;
import jade.lang.acl.ACLMessage;

public class DeleteSenderBehaviour extends OneShotBehaviour {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String idEvent;
	private String receiver;
	
	public DeleteSenderBehaviour(String content) {
		
		String[] split = content.split("/-/");
		
		this.receiver = split[0];
		this.idEvent = split[1];
	}

	@Override
	public void action() {
		
		ACLMessage message = new ACLMessage(ACLMessage.CANCEL);
		message.setSender(myAgent.getAID());
		message.addReceiver(new AID(receiver, AID.ISLOCALNAME));
		message.setConversationId("SERVER-CANCEL-EVENT");
		
		message.setContent(idEvent);
		
		myAgent.send(message);
	}
}
